<?php

namespace App\Models\Shop;

use App\Models\BaseModel;
use Illuminate\Http\Request;

class ShopGoodsBillModel extends BaseModel
{
    protected $table = 'shop_goods_bill';

    protected $primaryKey = 'goods_id';

    public $dateFormat = 'U';

    public function goods()
    {
        return $this->belongsTo('App\Models\Shop\ShopGoodsModel','goods_id','goods_id');
    }


    public function addPrice(Request $request,$goods_id)
    {

        $bill = self::findOrNew($goods_id);
        $bill->goods_id = $goods_id;
        $bill->price = $request->post('price');
        $bill->cost_price = $request->post('cost_price',0);
        $bill->market_price = $request->post('market_price',0);
        $bill->agent_price = $request->post('agent_price',0);
        $bill->award_xj = $request->post('award_xj',0);
        $bill->award_gw = $request->post('award_gw',0);
        $bill->award_xf = $request->post('award_xf',0);
        return $bill->save();
    }

}
